$(function(){
	$(".selector").each(function() {
		 $(this).selectorInit();
	});	
	var power_str = $("input[name='power_str']").val();
	var power_arr = power_str.split(',');
	for(var i=0; i<power_arr.length; i++){
		$("input[value='" + power_arr[i] + "']").attr("checked", true);
	}
	$(".submit").click(function(){
		var id = $(this).attr('id');
		var m_id = id.substr(7);
		var interface_arr = Array();
		var webpage_id = $("input[name='webpage_id']").val();
		$("#module_" + m_id + " input:checked").each(function(i){
			interface_arr[i] = $(this).val();
		});
		var action = 'editWebpagePower';
		var post = {action:action, webpage_id:webpage_id, module_id:m_id, interface_arr:interface_arr};
		var url = "aj_wpPower.php";
		$.post(url, post, function(json){
			if(json.status == 1){
				var new_power = json.power;
				$("#power_now").text(new_power);
				showCommonLayer("编辑成功", 4);				
			}else{
				var error_msg = json.msg;
				showCommonLayer(error_msg, 5);
			}
			
		}, 'json');
	});
})
